package com.example.android.ui.register;

import com.example.android.bean.Register;
import com.example.android.network.RetrofitClientLocal;
import com.example.android.network.service.RegisterService;

import org.json.JSONObject;

import java.util.HashMap;

import io.reactivex.rxjava3.core.Flowable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class RegisterModel implements RegisterContract.IRegisterModel {
    @Override
    public Flowable<Register> addUser(String userAccount, String userMobile, String userPassword) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("userAccount", userAccount);
        map.put("userMobile", userMobile);
        map.put("userPassword", userPassword);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new JSONObject(map).toString());
        return RetrofitClientLocal.getInstance().getService(RegisterService.class).addUser(requestBody);
    }
}
